import React from 'react';
import { Select } from 'antd';

const SingleSelect = (props, ref) => {
  const Option = Select.Option;
  let {
    value,
    onChange = () => {},
    fieldProps = {},
  } = props;
  const { placeholder = '请选择', options = [] } = fieldProps
  return (
    <Select
      style={{ width: '100%' }}
      allowClear
      placeholder={placeholder}
      value={value}
      {...fieldProps}
      onChange={onChange}
    >
      {options &&
        options.map((item) => (
          <Option value={item.value} key={item.value}>
            {item.label}
          </Option>
        ))}
    </Select>
  );
};

export default React.forwardRef(SingleSelect);
